package com.xoa.dev.keyYouth.controller;

import com.xoa.dev.keyYouth.model.CVehicles;
import com.xoa.dev.keyYouth.service.CVehiclesService;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/cVehicles")
public class CVehiclesController {
    
    @Autowired
    private CVehiclesService cVehiclesService;


    // 导航
    @RequestMapping("/index")
    public String index() {
        return "app/dev/CVehicles/index";
    }
    // 列表页
    @RequestMapping("/list")
    public String list() {
        return "app/dev/CVehicles/list";
    }

    // 新增修改详情页
    @RequestMapping("/add")
    public String add() {
        return "app/dev/CVehicles/add";
    }

    //添加
    @RequestMapping("/addCVehicles")
    @ResponseBody
    public ToJson addCVehicles(HttpServletRequest request,CVehicles record){
        return cVehiclesService.addCVehicles(request,record);
    }
    //查询 分页
    @RequestMapping("/selectCVehicles")
    @ResponseBody
    public ToJson selectCVehicles(Integer page, Integer pageSize, Boolean useFlag, CVehicles record
    ){
        return cVehiclesService.selectCVehicles(page,pageSize,useFlag,record);
    }
    //编辑
    @RequestMapping("/updateCVehicles")
    @ResponseBody
    public ToJson updateCVehicles(HttpServletRequest request,CVehicles record){
        return cVehiclesService.updateCVehicles(request,record);
    }
    //详情
    @RequestMapping("/selectCVehiclesInfo")
    @ResponseBody
    public ToJson selectCVehiclesInfo(Integer id){
        return cVehiclesService.selectInofCVehicles(id);
    }
    //删除
    @RequestMapping("/deleteCVehicles")
    @ResponseBody
    public ToJson deleteCVehicles(HttpServletRequest request,Integer id){
        return cVehiclesService.deleteCVehicles(request,id);
    }


    //下拉菜单
    @RequestMapping("/names")
    @ResponseBody
    public ToJson names(){
        return cVehiclesService.names();
    }
    /**
     * 批量删除
     *
     * @param deleteIds 主键拼接字符串
     * @return ToJson
     */
    @ResponseBody
    @PostMapping("/delete")
    public ToJson delete(String deleteIds) {
        return cVehiclesService.delete(deleteIds);
    }





}
